import React from "react";
import propTypes from "prop-types"; // 校验规则

class Son extends React.Component {
    static propTypes = {
        str: propTypes.string,
        num: propTypes.number,
        obj: propTypes.object,
        func: propTypes.func,
    };
    static defaultProps = {
        str: "我是字符串的默认值",
    };
    render() {
        return <div>{this.props.str}</div>;
    }
}
// function Son(props) {
//     return <div>{props.str}</div>;
// }
// react校验props的方式
// Son.propTypes = {
//     str: propTypes.string,
// };
// Son.defaultProps
class AppClass extends React.Component {
    render() {
        return (
            <div>
                <Son
                    str={"我是传入的值"}
                    num={123}
                    obj={{}}
                    func={() => {}}></Son>
            </div>
        );
    }
}

export default AppClass;
